﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Account/Site.master" AutoEventWireup="true" CodeFile="LienHe.aspx.cs" Inherits="Administrator_LienHe" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" 
        Font-Size="0.8em" PathSeparator=" : " style="font-size: small">
        <CurrentNodeStyle ForeColor="#333333" />
        <NodeStyle Font-Bold="True" ForeColor="#284E98" />
        <PathSeparatorStyle Font-Bold="True" ForeColor="#507CD1" />
        <RootNodeStyle Font-Bold="True" ForeColor="#507CD1" />
    </asp:SiteMapPath>
    <br />
    <asp:Label ID="Label1" runat="server" 
        style="font-size: x-large; font-weight: 700" Text="Quản lý liên hệ"></asp:Label>
    <br />
    <br />
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" 
        DataSourceID="SqlDataSource1" EnableModelValidation="True" Width="100%" 
        CellPadding="3" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" 
        BorderWidth="1px">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" >
            <ItemStyle Width="20px" />
            </asp:CommandField>
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                ReadOnly="True" SortExpression="ID" >
            <ItemStyle Width="20px" />
            </asp:BoundField>
            <asp:BoundField DataField="Ten" HeaderText="Tên" SortExpression="Ten" />
            <asp:BoundField DataField="DiaChi" HeaderText="Địa chỉ" 
                SortExpression="DiaChi" />
            <asp:BoundField DataField="DienThoai" HeaderText="Điện thoại" 
                SortExpression="DienThoai" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
        </Columns>
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
        <RowStyle ForeColor="#000066" />
        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
        DeleteCommand="DELETE FROM [LienLac] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [LienLac] ([Ten], [DiaChi], [DienThoai], [Email]) VALUES (@Ten, @DiaChi, @DienThoai, @Email)" 
        SelectCommand="SELECT * FROM [LienLac]" 
        UpdateCommand="UPDATE [LienLac] SET [Ten] = @Ten, [DiaChi] = @DiaChi, [DienThoai] = @DienThoai, [Email] = @Email WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Ten" Type="String" />
            <asp:Parameter Name="DiaChi" Type="String" />
            <asp:Parameter Name="DienThoai" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Ten" Type="String" />
            <asp:Parameter Name="DiaChi" Type="String" />
            <asp:Parameter Name="DienThoai" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" 
        DataSourceID="SqlDataSource1" EnableModelValidation="True">
        <EditItemTemplate>
            ID:
            <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
            <br />
            Ten:
            <asp:TextBox ID="TenTextBox" runat="server" Text='<%# Bind("Ten") %>' />
            <br />
            DiaChi:
            <asp:TextBox ID="DiaChiTextBox" runat="server" Text='<%# Bind("DiaChi") %>' />
            <br />
            DienThoai:
            <asp:TextBox ID="DienThoaiTextBox" runat="server" 
                Text='<%# Bind("DienThoai") %>' />
            <br />
            Email:
            <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <EmptyDataTemplate>
            Không có dữ liệu (Click Tạo mới )<br />
            <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Tạo mới</asp:LinkButton>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <table class="style1">
                <tr>
                    <td>
                        Tên :</td>
                    <td>
                        <asp:TextBox ID="TenTextBox" runat="server" Text='<%# Bind("Ten") %>' />
                    </td>
                    <td>
                        Địa chỉ :</td>
                    <td>
                        <asp:TextBox ID="DiaChiTextBox" runat="server" Text='<%# Bind("DiaChi") %>' />
                    </td>
                    <td>
                        Điện thoại :</td>
                    <td>
                        <asp:TextBox ID="DienThoaiTextBox" runat="server" 
                            Text='<%# Bind("DienThoai") %>' />
                    </td>
                    <td>
                        Email:</td>
                    <td>
                        <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>' />
                    </td>
                </tr>
            </table>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="TenTextBox" Display="None" 
                ErrorMessage="Tên không được rỗng"></asp:RequiredFieldValidator>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ControlToValidate="DienThoaiTextBox" Display="None" 
                ErrorMessage="Điên thoại không được rỗng"></asp:RequiredFieldValidator>
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" 
                onclick="InsertCancelButton_Click" />
        </InsertItemTemplate>
        <ItemTemplate>
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="Tạo mới" />
        </ItemTemplate>
    </asp:FormView>
    <br />
</asp:Content>

